//初始化按钮点击事件

let initBox = document.querySelector(".init")
initBox.addEventListener("click", function () {
  axios.get('/init/data').then(res => {
    const { data: result } = res
    if (result.status === 0) {
      console.log(result);
    }

  }).catch(res => {

  })
})



//登录退出点击事件
const logout = document.querySelector(".logout a")
logout.addEventListener("click", function () {
  if (confirm('你确定退出吗')) {
    localStorage.removeItem("token")
    location.href = './login.html'
  }
})


//一级标题点击事件
const oneMenuTitleAs = document.querySelectorAll(".nav>li>a")
oneMenuTitleAs.forEach(item => {
  item.addEventListener("click", function () {
    // console.log(this.innerText);
    this.querySelector(".toggle").classList.toggle("toggleDown")
    this.nextElementSibling.classList.toggle("show")
  })
})

//二级标题点击事件
const twoMenuTitleAs = document.querySelectorAll(".nav ul a")
twoMenuTitleAs.forEach(item => {
  item.addEventListener("click", function () {
    document.querySelector(".nav ul a.active").classList.remove("active")
    this.classList.add("active")
  })
})